package com.qf.utils;

import com.qf.pojo.MailBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

public class SendEmailUtil {

    @Value("${spring.mail.username}")
    private static String MAIL_SENDER;

    @Autowired
    private static JavaMailSender javaMailSender;


    public static void sendManage(MailBean mailBean){
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(MAIL_SENDER);
        simpleMailMessage.setTo(mailBean.getRecipient());
        simpleMailMessage.setSubject(mailBean.getSubject());
        simpleMailMessage.setText(mailBean.getContent());
        javaMailSender.send(simpleMailMessage);
    }
}
